setInterval("ajaxpro()", 2000);

// ajaxpro();

function ajaxpro() {
    var geturl = "/index/index/ajaxindexpro";
    var type = '';
    $.get(geturl, function (data) {
        if (data) {
            data = data;
            var str = "";
            var str2 = "";
            var i = 0;
            var color = "";
            var fh = "";
            var flag = "";
            var dataArr = [];
            var arr = [];
            var result = [];
            for (var i in data) {
                dataArr.push(data[i]);
            }
            dataArr.sort(function (a, b) {
                return a.proorder - b.proorder
            });
            for (var i = 0, len = dataArr.length; i < len; i += 3) {
                result.push(dataArr.slice(i, i + 3));
            }
            for (var i = 0; i < result.length; i++) {
                arr.push('<div class="swiper-slide">');
                arr.push('<div class="market-item">');
                for (var j = 0; j < result[i].length; j++) {
                    arr.push('<dl class="item-box">');
                    arr.push('<a href="/index/goods/goods/pid/' + result[i][j].pid + '">');
                    arr.push('<dt class="ng-binding prtitle">' + result[i][j].ptitle + '</dt>');
                    if (result[i][j].isup == 1) {
                        arr.push('<dd class="red"><p class="now-value">' + result[i][j].Price + '</p><span>' + result[i][j].zf + '%</span></dd>');
                    } else {
                        arr.push('<dd class="green"><p class="now-value">' + result[i][j].Price + '</p><span>' + result[i][j].zf + '%</span></dd>');
                    }
                    arr.push('</a>');
                    arr.push('</dl>');
                }
                arr.push('</div>');
                arr.push('</div>')
            }
            $(".product_list").html(arr.join(''));
            $(function () {
                var marketSwiper = new Swiper('.market-swiper-container', {
                    slidesPerView: 1,
                    spaceBetween: 10,
                    //pagination:  '.market-pagination',
                    // paginationClickable :true,
                })
            })

            var v = '';
            //$.each(data, function (k, v) {
            for (var k = 0, len = dataArr.length; k < len; k += 1) {
                v = dataArr[k];
                if (v.isopen == -1) {
                    color = 'style="color:#fff;"';
                    fh = "";
                    flag = 'xiu';
                } else if (v.isup == 1) {
                    color = 'style="color:red;"';
                    fh = "+";
                    flag = 'up';
                } else {
                    color = 'style="color:#03ad8f"';
                    fh = "-";
                    flag = 'down';
                }
                if (i % 3 == 0) {
                    str += '<div class="swiper-slide"><div class="market-item">';
                }
                str += '<dl class="item-box"><a href="/index/goods/goods/pid/' + v.pid + '"><dt class="ng-binding prtitle">' + v.ptitle + '</dt><dd><p class="now-value" ' + color + '>' + v.Price + '</p><span ' + color + '>' + fh + v.zf + '%</span></dd></a></dl>';
                if (i % 3 == 2) {
                    str += '</div></div>';
                }
                str2 += '<a href="/index/goods/goods/pid/' + v.pid + '"><div class="list-item"><div class="item-field"><div class="field-group"><span>' + v.ptitle + '</span><em></em></div></div><div class="item-field"><p>' + v.Price + '</p></div><div class="item-field"><span class="' + flag + '">' + fh + v.zf + '%</span></div></div></a>';
                i++;
                /*$('#pid'+v.pid+' .prtitle').html(v.ptitle);
                            $('#pid'+v.pid+' .now-value').html(v.Price);
                            $('#pid'+v.pid+' .rise-low').html(v.Low);
                            $('#pid'+v.pid+' .rise-high').html(v.High);

                            if(v.isup == 1){

                                    $('#pid'+v.pid+' .now-value').addClass('rise-value');
                                    $('#pid'+v.pid+' .now-value').removeClass('fall-value');

                                    $('#pid'+v.pid+' .rise-low').addClass('rise');
                                    $('#pid'+v.pid+' .rise-low').removeClass('fall');

                                    $('#pid'+v.pid+' .rise-high').addClass('rise');
                                    $('#pid'+v.pid+' .rise-high').removeClass('fall');

                            }else if(v.isup == 0){
                                    $('#pid'+v.pid+' .now-value').removeClass('rise-value');
                                    $('#pid'+v.pid+' .now-value').addClass('fall-value');

                                    $('#pid'+v.pid+' .rise-low').removeClass('rise');
                                    $('#pid'+v.pid+' .rise-low').addClass('fall');

                                    $('#pid'+v.pid+' .rise-high').removeClass('rise');
                                    $('#pid'+v.pid+' .rise-high').addClass('fall');
                            }*/

            }
            //});
            $(".list").html(str2);
        }
    });
}